<div class="row-content am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <div class="widget-head am-cf">
                    <div class="widget-title am-fl">新增设备</div>
                    <div class="widget-function am-fr">
                        <a href="javascript:;" class="am-icon-cog"></a>
                    </div>
                </div>
                <div class="widget-body am-fr">
                    <form class="am-form tpl-form-line-form" id="insureForm" method="post">
                        <input type="hidden" id="id" name="id" th:value="${record.id}"/>
                        <!--投保物品价格(insureResValue)-->
                        <div class="am-form-group">
                            <label for="insureResValue" class="am-u-sm-2 am-form-label">投保物品价格
                                <span class="tpl-form-line-small-title">InsureResValue</span>
                            </label>
                            <div class="am-u-sm-10">
                                <input type="text" id="insureResValue" class="tpl-form-input" placeholder="请输入"
                                       name="insureResValue"
                                       th:value="${record.plateNum != null} ? ${record.plateNum} : ''"/>
                            </div>
                        </div>
                        <!--投保年数(insureResYears)-->
                        <div class="am-form-group">
                            <label for="insureResYears" class="am-u-sm-2 am-form-label">投保年数
                                <span class="tpl-form-line-small-title">InsureResYears</span>
                            </label>
                            <div class="am-u-sm-10">
                                <input type="text" id="insureResYears" class="tpl-form-input" placeholder="请输入"
                                       name="insureResYears"
                                       th:value="${record.plateNum != null} ? ${record.plateNum} : ''"/>
                            </div>
                        </div>
                        <!--保费总额(insurePrice)-->
                        <div class="am-form-group">
                            <label for="insurePrice" class="am-u-sm-2 am-form-label">保费总额
                                <span class="tpl-form-line-small-title">InsurePrice</span>
                            </label>
                            <div class="am-u-sm-10">
                                <input type="text" id="insurePrice" class="tpl-form-input" placeholder="请输入"
                                       name="insurePrice"
                                       th:value="${record.plateNum != null} ? ${record.plateNum} : ''"/>
                            </div>
                        </div>
                        <!--投保人姓名(applicantName)-->
                        <div class="am-form-group">
                            <label for="applicantName" class="am-u-sm-2 am-form-label">投保人姓名
                                <span class="tpl-form-line-small-title">ApplicantName</span>
                            </label>
                            <div class="am-u-sm-10">
                                <input type="text" id="applicantName" class="tpl-form-input" placeholder="请输入"
                                       name="applicantName"
                                       th:value="${record.applicantName != null} ? ${record.applicantName} : ''"/>
                            </div>
                        </div>
                        <!--身份证号(identityNum)-->
                        <div class="am-form-group">
                            <label for="identityNum" class="am-u-sm-2 am-form-label">身份证号
                                <span class="tpl-form-line-small-title">IdentityNum</span>
                            </label>
                            <div class="am-u-sm-10">
                                <input type="text" id="identityNum" class="tpl-form-input" placeholder="请输入"
                                       name="identityNum"
                                       th:value="${record.identityNum != null} ? ${record.identityNum} : ''"/>
                            </div>
                        </div>
                        <!--保险人姓名(insurantName)-->
                        <div class="am-form-group">
                            <label for="insurantName" class="am-u-sm-2 am-form-label">保险人姓名
                                <span class="tpl-form-line-small-title">InsurantName</span>
                            </label>
                            <div class="am-u-sm-10">
                                <input type="text" id="insurantName" class="tpl-form-input" placeholder="请输入"
                                       name="insurantName"
                                       th:value="${record.insurantName != null} ? ${record.insurantName} : ''"/>
                            </div>
                        </div>
                        <!--被保险人姓名(insurantContact)-->
                        <div class="am-form-group">
                            <label for="insurantContact" class="am-u-sm-2 am-form-label">被保险人姓名
                                <span class="tpl-form-line-small-title">Title</span>
                            </label>
                            <div class="am-u-sm-10">
                                <input type="text" id="insurantContact" class="tpl-form-input" placeholder="请输入"
                                       name="insurantContact"
                                       th:value="${record.insurantContact != null} ? ${record.insurantContact} : ''"/>
                            </div>
                        </div>
                        <!--第一受益人姓名(beneficiaryName)-->
                        <div class="am-form-group">
                            <label for="beneficiaryName" class="am-u-sm-2 am-form-label">第一受益人姓名
                                <span class="tpl-form-line-small-title">BeneficiaryName</span>
                            </label>
                            <div class="am-u-sm-10">
                                <input type="text" id="beneficiaryName" class="tpl-form-input" placeholder="请输入"
                                       name="beneficiaryName"
                                       th:value="${record.beneficiaryName != null} ? ${record.beneficiaryName} : ''"/>
                            </div>
                        </div>
                        <!--发票抬头(invoiceTitle)-->
                        <div class="am-form-group">
                            <label for="invoiceTitle" class="am-u-sm-2 am-form-label">发票抬头
                                <span class="tpl-form-line-small-title">Title</span>
                            </label>
                            <div class="am-u-sm-10">
                                <input type="text" id="invoiceTitle" class="tpl-form-input" placeholder="请输入"
                                       name="invoiceTitle"
                                       th:value="${record.invoiceTitle != null} ? ${record.invoiceTitle} : ''"/>
                            </div>
                        </div>
                        <!--购买时间(resBuyDate)-->
                        <div class="am-form-group">
                            <label for="resBuyDate" class="am-u-sm-2 am-form-label">购买时间
                                <span class="tpl-form-line-small-title">ResBuyDate</span>
                            </label>
                            <div class="am-u-sm-10">
                                <input type="text" id="resBuyDate" class="form-control validate[required]"
                                       onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" name="resBuyDate"
                                       placeholder="请选择日期"
                                       th:value="${#dates.format(record.resBuyDate, 'yyyy-MM-dd')}"/>
                                <div class="input-group-btn">
                                </div>
                            </div>
                        </div>
                        <!--设备品牌(deviecBrand)-->
                        <div class="am-form-group">
                            <label for="deviecBrand" class="am-u-sm-2 am-form-label">设备品牌
                                <span class="tpl-form-line-small-title">DeviecBrand</span>
                            </label>
                            <div class="am-u-sm-10">
                                <input type="text" id="deviecBrand" class="tpl-form-input" placeholder="请输入"
                                       name="deviecBrand"
                                       th:value="${record.deviecBrand != null} ? ${record.deviecBrand} : ''"/>
                            </div>
                        </div>
                        <!--铭牌号(plateNum)-->
                        <div class="am-form-group">
                            <label for="plateNum" class="am-u-sm-2 am-form-label">铭牌号
                                <span class="tpl-form-line-small-title">PlateNum</span>
                            </label>
                            <div class="am-u-sm-10">
                                <input type="text" id="plateNum" class="tpl-form-input" placeholder="请输入"
                                       name="plateNum" th:value="${record.plateNum != null} ? ${record.plateNum} : ''"/>
                            </div>
                        </div>
                        <!--发动机铭牌号(enginePlateNum)-->
                        <div class="am-form-group">
                            <label for="enginePlateNum" class="am-u-sm-2 am-form-label">发动机铭牌号
                                <span class="tpl-form-line-small-title">EnginePlateNum</span>
                            </label>
                            <div class="am-u-sm-10">
                                <input type="text" id="enginePlateNum" class="tpl-form-input" placeholder="请输入"
                                       name="enginePlateNum"
                                       th:value="${record.enginePlateNum != null} ? ${record.enginePlateNum} : ''"/>
                            </div>
                        </div>
                        <!--邮寄地址(warrantReceiptorAddres)-->
                        <div class="am-form-group">
                            <label for="warrantReceiptorAddres" class="am-u-sm-2 am-form-label">邮寄地址
                                <span class="tpl-form-line-small-title">WarrantReceiptorAddres</span>
                            </label>
                            <div class="am-u-sm-10">
                                <input type="text" id="warrantReceiptorAddres" class="tpl-form-input" placeholder="请输入"
                                       name="warrantReceiptorAddres"
                                       th:value="${record.warrantReceiptorAddres != null} ? ${record.warrantReceiptorAddres} : ''"/>
                            </div>
                        </div>
                        <!--身份证正面照（identityPositiveImage）-->
                        <div class="am-form-group">
                            <label for="identityPositiveImage" class="am-u-sm-2 am-form-label">身份证正面照
                                <span class="tpl-form-line-small-title">IdentityPositiveImage</span>
                            </label>
                            <div class="am-u-sm-10">
                                <input id="upFile" type="file"/>
                                <input id="identityPositiveImage" type="hidden" name="identityPositiveImage"
                                       th:value="${record.identityPositiveImage != null} ? ${record.identityPositiveImage} : ''"/>
                            </div>
                        </div>
                        <!--身份证背面照（identityOppositeImage）-->
                        <div class="am-form-group">
                            <label for="identityOppositeImage" class="am-u-sm-2 am-form-label">身份证背面照
                                <span class="tpl-form-line-small-title">IdentityOppositeImage</span>
                            </label>
                            <div class="am-u-sm-10">
                                <input id="upFileTwo" type="file"/>
                                <input id="identityOppositeImage" type="hidden" name="identityOppositeImage"
                                       th:value="${record.identityOppositeImage != null} ? ${record.identityOppositeImage} : ''"/>
                            </div>
                        </div>
                        <!--操作-->
                        <div class="am-form-group">
                            <div class="am-u-sm-10 am-u-sm-push-2">

                                <button type="button" onclick="return doSubmit();"
                                        class="am-btn am-btn-primary tpl-btn-bg-color-success ">提交
                                </button>
                                <button type="button" onclick="loadPage('insure/listUI')"
                                        class="am-btn am-btn-success tpl-btn-bg-color-success ">返回
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script th:inline="javascript">
    <![CDATA[
    //$('select').selected();
    validateUserForm();

    function validateUserForm() {
        valdater = $('#insureForm').validate({
            errorElement: 'span',
            errorClass: 'am-icon-times',
            focusInvalid: true,
            onkeyup: false,
            ignore: "",
            rules: {
                title: {
                    required: true
                }
            },
            messages: {
                name: {
                    required: "请填写标题"
                }
            }
        });
    }

    function doSubmit() {
        if (valdater.form()) {
            commit('insureForm', 'insure/save', 'insure/listUI');
            return true;
        }
        return false;
    }

    var initImg_p = [];
    var initImg_o = [];
    var img_p = [[${record.identityPositiveImage != null?record.identityPositiveImage:''}]];

    var img_o = [[${record.identityOppositeImage != null?record.identityOppositeImage:''}]];

    if (img_p != '') {
        initImg_p.push("<img height='160px' src='" + img_p + "' class='file-preview-image' alt='' title=''>");
    }
    if (img_o != '') {
        initImg_o.push("<img height='160px' src='" + img_o + "' class='file-preview-image' alt='' title=''>");
    }

    initUpFileOne('upFile', 'identityPositiveImage', '身份证正面照', initImg_p);
    initUpFileOne('upFileTwo', 'identityOppositeImage', '身份证背面照', initImg_o);

    ]]>
</script>
<script type="text/javascript" th:src="@{/customer/registerLicense/list.js}"/>